$OpenBSD: patch-lib_rubygems_ext_builder_rb,v 1.3 2014/11/07 15:18:56 dcoppa Exp $

Ugly hack to make --user-install option work.  Without this, when
a user uses gem install --user-install, it calls
/usr/bin/install -o root -g bin, which fails due to permission issues.
This removes the -o root -g bin, so it can succeed as a regular user.

Gem::Installer.path_warning is only set if --user-install is used,
according to a grep of the sources.

Use MAKE or make from ENV over rbconfig's make.
https://github.com/rubygems/rubygems/commit/f2bad74dda8d8e463a092905f29c943c962d5e68

--- lib/rubygems/ext/builder.rb.orig	Wed Jul 27 04:04:03 2011
+++ lib/rubygems/ext/builder.rb	Fri Nov  7 12:35:55 2014
@@ -19,12 +19,13 @@ class Gem::Ext::Builder
     mf = File.read('Makefile')
     mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
     mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
+    mf = mf.gsub(/-o root -g bin/, "") unless Process.euid == 0
 
     File.open('Makefile', 'wb') {|f| f.print mf}
 
     # try to find make program from Ruby configure arguments first
     RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/
-    make_program = $1 || ENV['make']
+    make_program = ENV['MAKE'] || ENV['make'] || $1
     unless make_program then
       make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
     end
